package com.alibaba.goods.order.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.goods.order.entity.Commentresult;
import com.alibaba.goods.order.entity.Order;
import com.alibaba.goods.order.exception.BlockHandlerManager;
import com.alibaba.goods.order.exception.FallBackManager;
import com.alibaba.goods.order.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Author:RenPu
 * @Date: 2020/7/7 13:35
 * @Version: 1.0
 * @description:
 */

@RestController
@Slf4j
public class OrderController {


    @Resource
    private OrderService orderService;

    @GetMapping(value = "/order/createOrder")
    @SentinelResource(value = "orderdecrease",blockHandlerClass = BlockHandlerManager.class,blockHandler = "handlerExceptionManagerMethond",fallbackClass = FallBackManager.class,fallback = "fallBackManagerMethond")
    public Commentresult createOrder(Order order){

        //int i=10/0;
        orderService.create(order);

        return new Commentresult(200,"订单创建成功");
    }


    }
